<?php

require_once("Elements.php");

class AddFriend extends Zend_Form {
	
	private $user;
	
	public function AddFriend($user) {
		$this->user = $user;
		$this->__construct();
	}
	
	public function init() {
		$this->setMethod('post');
		$element = new Zend_Form_Element_Text('email');
		if (isset($this->user)) {
			$element->setAttrib('enabled', false);
			$element->setAttrib('readonly', true);
			$element->setValue($user->email);
		}
		$element->setLabel('朋友的Email:*');
		$element->setRequired(true);
						
		$element->addValidator(new Zend_Validate_EmailAddress());
		
		$element->addFilter(new Zend_Filter_HtmlEntities());
		$element->addFilter(new Zend_Filter_StripTags());
		$element->addValidator('NotEmpty');
		$this->addElement($element);
		
		$element = new Zend_Form_Element_Submit("Save");
		$element->setLabel('Save')->removeDecorator('DtDdWrapper');
		$element->setValue(0);
		$this->addElement($element);
	}
}
?>